package com.rybbaby.tss.front.tssClassSchedule.controller;

import com.rybbaby.tss.core.annotation.RequestLog;
import com.rybbaby.tss.core.annotation.Token;
import com.rybbaby.tss.core.utils.PropertiesReadUtil;
import com.rybbaby.tss.core.utils.StringUtils;
import com.rybbaby.tss.core.web.controller.BaseController;
import com.rybbaby.tss.front.tssClassSchedule.service.IViewTssClassScheduleService;
import com.rybbaby.tss.front.tssStudent.entity.TssStudent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import java.io.IOException;
import java.util.List;
import java.util.Map;

/**
 * @description 课表表管理
 * 
 * @author 雷春琼
 * 
 * @createDate 2017-08-09 下午11:52:12
 */
@Controller
@RequestMapping(value = "viewTssClassScheduleController")
public class ViewTssClassScheduleController extends BaseController {
	
	@Autowired
	private IViewTssClassScheduleService viewTssClassScheduleService;



	/**
	 * 获取课表信息
	 *
	 * @return
	 * @throws IOException
	 */
	@RequestLog(content = "获取课表信息", save = true)
	@Token(validateToken = false)
	@RequestMapping(value = "viewTssClassSchedule", method = RequestMethod.POST)
	public ModelAndView viewTssClassSchedule(@RequestParam(required = true) Integer type) {
		ModelAndView mav = null;
		try {

			if (type == 1) {
				//亲子课表
				mav = new ModelAndView(PropertiesReadUtil.getStringProperty("tssClassScheduleListView"));
			} else if (type == 2) {
				//过渡课表
				mav = new ModelAndView(PropertiesReadUtil.getStringProperty("tssTransitClassesRosterListView"));
			}
			List<Map<String,Object>> classScheduleMapList=this.viewTssClassScheduleService.viewTssClassSchedule(type);
			mav.addObject("classScheduleMapList", classScheduleMapList);
		} catch (Exception e) {
			throw e;
		}
		return mav;
	}

	/**
	 * 亲子课表全屏
	 *
	 * @param
	 */
	@RequestLog(content = "转到客户表视图", save = true)
	@Token(validateToken = false)
	@RequestMapping(value = "viewTssClassScheduleKissBaby", method = RequestMethod.GET)
	public ModelAndView viewTssClassScheduleKissBaby(TssStudent entity) {
		ModelAndView mav = new ModelAndView(PropertiesReadUtil.getStringProperty("viewTssClassScheduleKissBabyView"));

		mav.addObject("saveUrl", StringUtils.substringBeforeLast(request.getRequestURI(), "/") + "/saveOrUpdate.do");
		return mav;
	}

}
